#include "qtemplatenamewidget.h"
#include "ui_qtemplatenamewidget.h"

#include "qtemplatetreewidget.h"

#include "../../libs/coreLib/qtoolbarbutton.h"

#include <QTreeWidgetItem>

QTemplateNameWidget::QTemplateNameWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::QTemplateNameWidget)
{
    ui->setupUi(this);

    QAction *ac;

    ac=new QAction(QIcon(":/images/up.png"),"",this);
    ac->setToolTip("Move to template");
    m_up_button=new CORELIB::QToolBarButton(ac,this);
    ui->horizontalLayout->addWidget(m_up_button);
    connect(ac,SIGNAL(triggered()),this,SLOT(movetotemp()));

    ac=new QAction(QIcon(":/images/removesubmitfield.png"),"",this);
    ac->setToolTip("Remove");
    m_remove_button=new CORELIB::QToolBarButton(ac,this);
    ui->horizontalLayout->addWidget(m_remove_button);
    connect(ac,SIGNAL(triggered()),this,SLOT(remove()));


}

QTemplateNameWidget::~QTemplateNameWidget()
{
    delete ui;
}

void QTemplateNameWidget::setText(const QString &text)
{
    ui->name_label->setText(text);
}

void QTemplateNameWidget::movetotemp()
{
    m_tree->movetotemp(m_item);
}

void QTemplateNameWidget::remove()
{
    m_tree->remove(m_item);
}

void QTemplateNameWidget::set_tree_item(QTemplateTreeWidget *tree, QTreeWidgetItem *item)
{
    m_tree=tree;
    m_item=item;
}

void QTemplateNameWidget::set_up_button_visible(bool visible)
{
    m_up_button->setVisible(visible);
}
